package tu.cs.cs386.controllers;

import java.sql.ResultSet;
import java.sql.SQLException;

public class LoginController {
	
	public boolean checkLogin(String userName, String password){
		DBConnection dbConn = new DBConnection("sql353321",  "fR1*gD4*", 
				"jdbc:mysql://sql3.freemysqlhosting.net:3306/sql353321?zeroDateTimeBehavior=convertToNull");
		dbConn.openConnection();
		String cmd = "select * from UserAccounts where userName='"+userName+"' and loginPassword='"+ password +"';";
		ResultSet results = dbConn.executeStatement(cmd);
		boolean found = false ;
		try {
			if(results.next())
				found=true;
			else 
				found = false ;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		dbConn.closeConnection();

		return found;
	}
}
